<?php
namespace app\api\controller;
use think\Controller;


// test
class Admin extends Controller
{
    // test
    public function index(){
      // return  $this->fetch('test/test');

        file_put_contents('wx_sign.txt',json_encode($_GET));
        if($this->checkSignature())
        {
            die($_GET['echostr']);
        }
    }


    private function checkSignature()
    {
        $_GET["signature"];
        $_GET["timestamp"];
        $_GET["nonce"];

        $tmpArr = array($_GET["timestamp"], $_GET["nonce"],'oepkf2fl5ka29qelg');
        
        sort($tmpArr, SORT_STRING);
        $tmpStr = implode('',$tmpArr);
        $tmpStr = sha1( $tmpStr );

        if($_GET["signature"] ==  $tmpStr ){
            return true;
        }else{
            return false;
        }
    }
}
